package sy10_2;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) throws IOException {

        Socket client = new Socket("127.0.0.1",9999);

        OutputStream outputStream = client.getOutputStream();

        InputStream inputStream = client.getInputStream();

        Scanner input = new Scanner(System.in);

        while(true) {

            String s = input.nextLine();

            outputStream.write(("client:"+s).getBytes());

            byte[] b = new byte[1024];

            int len = inputStream.read(b);

            System.out.println(new String(b, 0, len));
        }

    }
}
